﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using GalaSoft.MvvmLight.Messaging;
using Miris.HumanMilkAnalyser.WPF.Shared;
using Miris.HumanMilkAnalyser.WPF.ViewModel;

namespace Miris.HumanMilkAnalyser.WPF
{
    /// <summary>
    /// Interaction logic for MainPage.xaml
    /// </summary>
    public partial class MainPage : PageBase
    {
        public MainPage()
        {
            InitializeComponent();
            InitializePageUnloadStoryboard();
        }

        protected override void RegisterMessages()
        {
            base.RegisterMessages();

            RegisterGoToNextPageMessage();
        }

        /// <summary>
        /// Register the GoToNextPageMessage from PatientBasicInfoViewModel.
        /// </summary>
        private void RegisterGoToNextPageMessage()
        {
            Messenger.Default.Register<MainPageViewModel>(this, MainPageViewModel.GoToNextPageMessageToken, p =>
            {
                try
                {
                    var mappingPage = new AnalysisResultMappingPage();
                    var viewModel = mappingPage.DataContext as AnalysisResultMappingViewModel;
                    viewModel.SetAnalysisResultProperties(p);

                    GoToPage(mappingPage);
                }
                catch (Exception ex)
                {
                    MyViewModelBase.RequestDisplayErrorMessage(ex.Message);
                }
            });
        }

        private void ButtonNext_Click(object sender, RoutedEventArgs e)
        {
            GoToPage(new AnalysisResultMappingPage());
        }
    }
}
